package com.qf;

import com.qf.conf.LoadBalancerConf;
import com.qf.conf.MyLoadBalancer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
//配置负载均衡
@LoadBalancerClient(value = "qf-order",configuration = LoadBalancerConf.class)
//开启feign客户端的支持
@EnableFeignClients
public class QFUserApplication {

    public static void main(String[] args) {
        SpringApplication.run(QFUserApplication.class, args);
    }

    @Bean
    @LoadBalanced //这个注解会向这个RestTemplate对象上绑定一个LoadBalancerInterceptor
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

}
